;Auto invoke DDATTE, DDEDIT or DIM NEW based upon filtered selection.
;       Routine will only select MTEXT, TEXT, ATTRIB, DIMENSION or
;       INSERT w/attrib. It will report the type of entity selected
;       if it cannot be edited via the above commands and prompt to
;       select again.
;
;	It was initially intended to be a command, hence the function name
;       C:.... Note that the variable pstr is required, e.g. (c:ded pstr).
;	pstr is simply the prompt string.  It is set in redefinition
;	of the commands that are affected in order to give the expected
;	prompts.  Invoke this routine from the redefined ddedit and ddatte.
;
;	AUTHOR: Henry C. Francis
;		425 N. ASHE ST.
;		SOUTHERN PINES, NC 28387
;		All rights reserved without prejudice.
;
;	Copyright:	10-3-95
;	Edited:		4-11-97
;
;       Changed selection window to set after each entsel pick.
;       Fixes unexpected selections following transparent zooms.
;
(command "undefine" "ddedit")
(command "undefine" "ddatte")
;==================================================================================================
(defun c:ddedit (/ pstr)
(setq pstr "\n<Select a TEXT or ATTDEF object> ")
  (if c:ded nil (load"ded"))
  (c:ded pstr)
)
;==================================================================================================
(defun c:ddatte (/ pstr)
(setq pstr "\nSelect block: ")
  (if c:ded nil (load"ded"))
  (c:ded pstr)
)
;==================================================================================================
(defun c:ed ( / ent tspt tspt1 tspt2); was (PSTR / ENT TSPT ....)
  (if dimscl nil (load"dimscl"))
  (dimscl)
  (while
    (setq tspt (cadr(entsel "\n<Select a TEXT or ATTDEF object>: ")))
    (setq scrnsz (getvar"screensize")
          viewsz (getvar"viewsize")
          pboxsz (*(/(* dimsc(/(cadr scrnsz)100))viewsz)1.5(getvar"pickbox"))
          tspt1 (polar tspt(* 1.25 pi)pboxsz)
          tspt2 (polar tspt(* 0.25 pi)pboxsz)
    )
    (COMMAND "RECTANG" TSPT1 TSPT2)
    (setq tss (ssget "C" tspt1 tspt2
                      '((-4 . "<OR")
                        (0 . "TEXT")
                        (0 . "MTEXT")
                        (0 . "ATTRIB")
                        (0 . "ATTDEF")
                        (0 . "DIMENSION")
                        (-4 . "<AND")
                          (0 . "INSERT")
                          (66 . 1)
                        (-4 . "AND>")
                      (-4 . "OR>")))
    );setq
;    (setq ent (entsel pstr))
    (if tss
      (progn
        (setq ent (ssname tss 0))
        (if (or
              (eq "TEXT" (cdr(assoc 0 (entget ent))))
              (eq "MTEXT" (cdr(assoc 0 (entget ent))))
              (eq "ATTDEF" (cdr(assoc 0 (entget ent))))
            )
          (progn
            (prompt (strcat "\n" (cdr(assoc 0 (entget ent))) " selected "))
            (prompt "\n<Select a TEXT or ATTDEF object> ")
            (command ".DDEDIT" ent)
          );progn
          (if (eq "INSERT" (cdr(assoc 0 (entget ent))))
            (progn
              (prompt (strcat "\nBLOCK selected "))
              (prompt "\nSelect Block: ")
              (command ".DDATTE" ent)
            );progn
            (if (eq "DIMENSION" (cdr(assoc 0 (entget ent))))
              (progn
                (setq dimstr (ustr 0 "Enter new dimension text or <enter> for Associative. " "" nil))
                (command ".dim" "new" dimstr (cdr(assoc -1 (entget ent)))"")
                (command)
              );progn
              (prompt (strcat "\n" (cdr(assoc 0 (entget ent))) " selected "))
            );if
          );if
        );if
        (command)
      );progn
      (princ "\nNo TEXT, ATTRIBUTE, BLOCK w/attribs, or DIMENSION selected. ")
    );if
  );while
  (command)
  (princ "\nFunction Cancelled. ")
  (princ)
);defun
